package com.hst.capacity.infra.persistence.jpa.fleet;



import com.hst.capacity.domain.model.entity.franchisee.fleet.FleetUserEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;


public interface FleetUserRepository extends JpaRepository<FleetUserEntity, String> {

    @Query("select fu " +
            "from FleetUserEntity fu " +
            "inner join FleetEntity f on fu.idFleet = f.idFleet " +
            "where fu.idFleetUser = :idFleetUser")
    FleetUserEntity findByIdFleetUser(@Param("idFleetUser") String idFleetUser);

    @Query("select fu " +
            "from FleetUserEntity fu " +
            "inner join FleetEntity f on fu.idFleet = f.idFleet " +
            "where fu.mobile = :mobile")
    FleetUserEntity findByMobile(@Param("mobile") String mobile);

    @Query("select fu from FleetUserEntity fu " +
            "inner join FleetEntity f on fu.idFleet = f.idFleet " +
            "where fu.idFleet = :idFleet")
    Page<FleetUserEntity> findByIdFleet(@Param("idFleet") String idFleet, PageRequest pageRequest);

}
